// import { wxLogin } from "./config/api";
App({
    getUserInfo(e, callback) {
        wx.login({
            success(res) {
                if (res.code) {
                    console.log(res, "微信登录返回值");
                    // console.log(e, "登录信息");
                    let userInfo = e.detail.userInfo;
                    // let userInfo = e.detail.rawData;
                    let encryptedData = e.detail.encryptedData;
                    let iv = e.detail.iv;
                    let code = res.code;

                    //微信授权登录
                    // wxLogin({ code, encryptedData, iv }).then((data) => {
                    //     if (data.status === 200) {
                    //         // console.log(data, "登录返回值111");
                    //         wx.setStorageSync("token", data.data.token);
                    //         wx.setStorageSync("mobile", data.data.mobile);
                    //         // wx.setStorageSync("mobile", data.data.mobile);
                    //         // wx.setStorageSync("userInfo", data.data.userInfo);
                    //         // wx.setStorageSync("loginPhone", data.data.userInfo.phone);

                    //         // 执行回调函数
                    //         callback && callback();
                    //     }
                    // });
                } else {
                    console.log("登录失败！" + res.errMsg);
                }
            },
        });
    },
    checkIsLogin() {
        // 验证登录
        return wx.getStorageSync("token") !== "";
    },
    onLaunch() {

    },
    formatNumber(n) {
        n = n.toString();
        return n[1] ? n : "0" + n;
    },
    getNowDays(day = 0) {
        let today, nowDate, ms;
        today = new Date();
        ms = today.getTime() + day * 24 * 60 * 60 * 1000;
        nowDate = new Date(ms);
        // console.log(nowDate.getDate(), "日期");
        return `${nowDate.getFullYear()}-${this.formatNumber(nowDate.getMonth() + 1)}-${this.formatNumber(nowDate.getDate())}`
    }
});